/*
 *
 *  Copyright (c) 2018-2025, Pactera JinXin Software All rights reserved.
 *
 */

import request from '@/router/axios'

export function fetchList(query) {
    return request({
        url: '/admin/user/page',
        method: 'get',
        params: query
    })
}

export function addObj(obj) {
    return request({
        url: '/admin/user',
        method: 'post',
        data: obj
    })
}

export function getObj(id) {
    return request({
        url: '/admin/user/' + id,
        method: 'get'
    })
}

export function delObj(id) {
    return request({
        url: '/admin/user/' + id,
        method: 'delete'
    })
}

export function putObj(obj) {
    return request({
        url: '/admin/user',
        method: 'put',
        data: obj
    })
}

export function getDetails(obj) {
    return request({
        url: '/admin/user/details/' + obj,
        method: 'get'
    })
}

export function fetchUserList(deptId, query) {
    return request({
        url: "/admin/user/dept/?deptId=" + deptId,
        method: "get",
        params: query
    });
}

// 查询部门下级部门列表及其本部用户
export function fetchChildrens(deptId) {
    return request({
        url: `/admin/dept/getLineDeptChildrens/${deptId}`,
        method: 'get'
    })
}

// 获取部门已调整成员情况
export function fetchLineList(deptId) {
    return request({
        url: `/admin/dept/getLineDeptSelected/${deptId}`,
        method: 'get'
    })
}

// 成员调整
export function updateLineList(obj) {
    return request({
        url: `/admin/dept/updateUsersToLineDept`,
        method: 'post',
        data: obj
    })
}

// 重置密码
export function resetPwd(userId) {
    return request({
        url: `/admin/user/resetPwd`,
        method: 'put',
        params: { userId }
    })
}